package com.czy.owner.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.czy.owner.R;
import com.czy.owner.entity.ShoppingModel;
import com.czy.owner.global.Constants;
import com.czy.owner.ui.hotshop.GoodsListActivity;
import com.czy.owner.ui.hotshop.HotShopWebActivity;
import com.czy.owner.utils.glide.GlideUtils;
import com.czy.owner.widget.NoScrollRecyclerView;
import com.easyrecycleview.adapter.BaseViewHolder;
import com.easyrecycleview.adapter.RecyclerArrayAdapter;
import com.easyrecycleview.decoration.DividerGridItemDecoration;

import java.util.ArrayList;

/**
 * Created by asus on 2017/12/20.
 */

public class ShoppingSpecialAdapter extends RecyclerArrayAdapter<ShoppingModel.SpecialListBean> {
    private static final int SPECIAL_TYPE0 = 0;
    private static final int SPECIAL_TYPE1 = 1;
    private static final int SPECIAL_TYPE2 = 2;
    private static final int SPECIAL_TYPE3 = 3;
    private static final int SPECIAL_TYPE4 = 4;
    private static final int SPECIAL_TYPE5 = 5;
    private static final int SPECIAL_TYPE6 = 6;
    private static final int SPECIAL_TYPE7 = 7;


    private static final int PLATFORM_TYPE = 0;
    private static int CLASSIFY_TYPE = 0;
    private Context mContext;


    public ShoppingSpecialAdapter(Context context) {
        super(context);
        mContext = context;

    }

    @Override
    public int getViewType(int position) {
        int specialSubjectTemplateId = getAllData().get(position).getSpecialSubjectTemplateId();
        if (specialSubjectTemplateId > 7) {
            specialSubjectTemplateId = 7;
        } else if (specialSubjectTemplateId > 1) {
            --specialSubjectTemplateId;
        } else {
            specialSubjectTemplateId = 0;
        }
        return specialSubjectTemplateId;

    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        ShoppingSpecialViewHolder viewHolder;
        switch (viewType) {
            case SPECIAL_TYPE2:
                viewHolder = new ShoppingSpecialViewHolder(parent, R.layout.layout_shoping_type2);
                break;
            default:
                viewHolder = new ShoppingSpecialViewHolder(parent, R.layout.layout_shoping_type1);
                break;
        }
        return viewHolder;
    }

    private class ShoppingSpecialViewHolder extends BaseViewHolder<ShoppingModel.SpecialListBean> {
        private TextView tvSpecialName;
        private TextView tvSpecialMore;
        private ImageView ivSpecialArrow;
        private View viewSpecialLine;
        private ImageView ivSpecialSubject;
        private NoScrollRecyclerView rvSpecial1;
        private NoScrollRecyclerView rvSpecial2;

        public ShoppingSpecialViewHolder(ViewGroup parent, int res) {
            super(parent, res);
            tvSpecialName = $(R.id.tv_special_name);
            tvSpecialMore = $(R.id.tv_special_more);
            ivSpecialArrow = $(R.id.iv_special_arrow);
            viewSpecialLine = $(R.id.view_special_line);
            ivSpecialSubject = $(R.id.iv_special_subject);
            rvSpecial1 = $(R.id.rv_special1);
            rvSpecial2 = $(R.id.rv_special2);

        }


        @Override
        public void setData(final ShoppingModel.SpecialListBean data) {
            super.setData(data);
            int layoutPosition = getLayoutPosition();
            tvSpecialName.setText(data.getSubjectName());
            if (data.getSpecialSubjectTemplateId() == 7 || data.getSpecialSubjectTemplateId() == 8) {

                viewSpecialLine.setVisibility(View.INVISIBLE);
                ivSpecialSubject.setVisibility(View.VISIBLE);
            } else {


                viewSpecialLine.setVisibility(View.VISIBLE);
                ivSpecialSubject.setVisibility(View.GONE);
            }
            if ("subject".equals(data.getSubjectType())) {
                ivSpecialArrow.setVisibility(View.INVISIBLE);
                tvSpecialMore.setVisibility(View.INVISIBLE);
            } else {
                ivSpecialArrow.setVisibility(View.VISIBLE);
                tvSpecialMore.setVisibility(View.VISIBLE);
            }
            tvSpecialMore.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(mContext, GoodsListActivity.class);
                    intent.putExtra("fromType", CLASSIFY_TYPE);
                    intent.putExtra("categoryId", data.getCategoryId());
                    intent.putExtra("goodsType", PLATFORM_TYPE);
                    intent.putExtra("title", data.getSubjectName());
                    intent.putExtra("mFromType", Constants.GOODSSOURCE_SPECIAL);
                    intent.putExtra("mFromTypeId", data.getSpecialSubjectId()+"");
                    mContext.startActivity(intent);
                }
            });
            ivSpecialSubject.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {


                    if (data.getSubList() != null && data.getSubList().size() >= 1) {

                        if ("category".equals(data.getSubList().get(0).getLinkType())) {
                            Intent intent = new Intent(mContext, GoodsListActivity.class);
                            intent.putExtra("fromType", CLASSIFY_TYPE);
                            intent.putExtra("categoryId", data.getSubList().get(0).getLinkTypeId());
                            intent.putExtra("goodsType", PLATFORM_TYPE);
                            intent.putExtra("title", data.getSubList().get(0).getTitle());
                            intent.putExtra("mFromType", Constants.GOODSSOURCE_SPECIAL);
                            intent.putExtra("mFromTypeId", data.getSpecialSubjectId()+"");
                            mContext.startActivity(intent);
                        } else if ("url".equals(data.getSubList().get(0).getLinkType())) {
                            Intent intent = new Intent(mContext, HotShopWebActivity.class);
                            intent.putExtra("title", data.getSubList().get(0).getTitle());
                            intent.putExtra("url", data.getSubList().get(0).getUrl());
                            mContext.startActivity(intent);
                        }

                    }

                }
            });
            if (data.getSubList() != null && data.getSubList().size() >= 1) {
                GlideUtils.loadImage(mContext, data.getSubList().get(0).getLogo(), ivSpecialSubject, null, R.mipmap.default_banner, R.mipmap.default_banner);
            }

            switch (getViewType(layoutPosition)) {
                case SPECIAL_TYPE0:
                    tvSpecialName.setTextColor(mContext.getResources().getColor(R.color.black));
                    SpecialSubAdapter specialSubAdapter = new SpecialSubAdapter(mContext, SPECIAL_TYPE0);
                    rvSpecial1.setLayoutManager(new GridLayoutManager(mContext, 2));
                    if (data.getSubList().size() > 0) {
                        ArrayList<ShoppingModel.SpecialListBean.SubListBean> subListBeans = new ArrayList<>();
                        for (int i = 0; i < (data.getSubList().size() > 2 ? 2 : data.getSubList().size()); i++) {
                            subListBeans.add(data.getSubList().get(i));
                        }
                        specialSubAdapter.addAll(subListBeans);
                    }

                    rvSpecial1.setAdapter(specialSubAdapter);
                    rvSpecial1.addItemDecoration(new DividerGridItemDecoration(mContext));
                    specialSubAdapter.setOnItemClickListener(new OnItemClickListener<ShoppingModel.SpecialListBean.SubListBean>() {
                        @Override
                        public void onItemClick(View view, int position, ShoppingModel.SpecialListBean.SubListBean o) {

                            if ("category".equals(o.getLinkType())) {
                                Intent intent = new Intent(mContext, GoodsListActivity.class);
                                intent.putExtra("fromType", CLASSIFY_TYPE);
                                intent.putExtra("categoryId", o.getLinkTypeId());
                                intent.putExtra("goodsType", PLATFORM_TYPE);
                                intent.putExtra("title", o.getTitle());
                                intent.putExtra("mFromType", Constants.GOODSSOURCE_SPECIAL);
                                intent.putExtra("mFromTypeId", data.getSpecialSubjectId()+"");
                                mContext.startActivity(intent);
                            } else if ("url".equals(o.getLinkType())) {
                                Intent intent = new Intent(mContext, HotShopWebActivity.class);
                                intent.putExtra("title", o.getTitle());
                                intent.putExtra("url", o.getUrl());
                                mContext.startActivity(intent);
                            }
                        }
                    });
                    break;
                case SPECIAL_TYPE1:

                    tvSpecialName.setTextColor(mContext.getResources().getColor(R.color.holo_red_light));
                    SpecialSubAdapter specialSubAdapter1 = new SpecialSubAdapter(mContext, SPECIAL_TYPE1);
                    rvSpecial1.setLayoutManager(new GridLayoutManager(mContext, 2));
                    if (data.getSubList().size() > 0) {
                        ArrayList<ShoppingModel.SpecialListBean.SubListBean> subListBeans = new ArrayList<>();
                        for (int i = 0; i < (data.getSubList().size() > 2 ? 2 : data.getSubList().size()); i++) {
                            subListBeans.add(data.getSubList().get(i));
                        }
                        specialSubAdapter1.addAll(subListBeans);
                    }
                    rvSpecial1.setAdapter(specialSubAdapter1);
                    rvSpecial1.addItemDecoration(new DividerGridItemDecoration(mContext));
                    specialSubAdapter1.setOnItemClickListener(new OnItemClickListener<ShoppingModel.SpecialListBean.SubListBean>() {
                        @Override
                        public void onItemClick(View view, int position, ShoppingModel.SpecialListBean.SubListBean o) {

                            if ("category".equals(o.getLinkType())) {
                                Intent intent = new Intent(mContext, GoodsListActivity.class);
                                intent.putExtra("fromType", CLASSIFY_TYPE);
                                intent.putExtra("categoryId", o.getLinkTypeId());
                                intent.putExtra("goodsType", PLATFORM_TYPE);
                                intent.putExtra("title", o.getTitle());
                                intent.putExtra("mFromType", Constants.GOODSSOURCE_SPECIAL);
                                intent.putExtra("mFromTypeId", data.getSpecialSubjectId()+"");
                                mContext.startActivity(intent);
                            } else if ("url".equals(o.getLinkType())) {
                                Intent intent = new Intent(mContext, HotShopWebActivity.class);
                                intent.putExtra("title", o.getTitle());
                                intent.putExtra("url", o.getUrl());
                                mContext.startActivity(intent);
                            }
                        }
                    });
                    break;
                case SPECIAL_TYPE2:

                    tvSpecialName.setTextColor(mContext.getResources().getColor(R.color.shopping_blue));
                    SpecialSubAdapter specialSubAdapter2 = new SpecialSubAdapter(mContext, SPECIAL_TYPE1);
                    rvSpecial1.setLayoutManager(new GridLayoutManager(mContext, 1));
                    if (data.getSubList().size() >= 1) {
                        specialSubAdapter2.add(data.getSubList().get(0));
                    }

                    rvSpecial1.setAdapter(specialSubAdapter2);
                    rvSpecial1.addItemDecoration(new DividerGridItemDecoration(mContext));

                    specialSubAdapter2.setOnItemClickListener(new OnItemClickListener<ShoppingModel.SpecialListBean.SubListBean>() {
                        @Override
                        public void onItemClick(View view, int position, ShoppingModel.SpecialListBean.SubListBean o) {

                            if ("category".equals(o.getLinkType())) {
                                Intent intent = new Intent(mContext, GoodsListActivity.class);
                                intent.putExtra("fromType", CLASSIFY_TYPE);
                                intent.putExtra("categoryId", o.getLinkTypeId());
                                intent.putExtra("goodsType", PLATFORM_TYPE);
                                intent.putExtra("title", o.getTitle());
                                intent.putExtra("mFromType", Constants.GOODSSOURCE_SPECIAL);
                                intent.putExtra("mFromTypeId", data.getSpecialSubjectId()+"");
                                mContext.startActivity(intent);
                            } else if ("url".equals(o.getLinkType())) {
                                Intent intent = new Intent(mContext, HotShopWebActivity.class);
                                intent.putExtra("title", o.getTitle());
                                intent.putExtra("url", o.getUrl());
                                mContext.startActivity(intent);
                            }
                        }
                    });
                    ;
                    SpecialSubAdapter specialSubAdapter3 = new SpecialSubAdapter(mContext, SPECIAL_TYPE2);
                    rvSpecial2.setLayoutManager(new LinearLayoutManager(mContext));
                    if (data.getSubList().size() > 1) {
                        ArrayList<ShoppingModel.SpecialListBean.SubListBean> subListBeans = new ArrayList<>();
                        for (int i = 1; i < (data.getSubList().size() > 3 ? 3 : data.getSubList().size()); i++) {
                            subListBeans.add(data.getSubList().get(i));
                        }
                        specialSubAdapter3.addAll(subListBeans);
                    }

                    rvSpecial2.setAdapter(specialSubAdapter3);

                    rvSpecial2.addItemDecoration(new DividerGridItemDecoration(mContext));
                    specialSubAdapter3.setOnItemClickListener(new OnItemClickListener<ShoppingModel.SpecialListBean.SubListBean>() {
                        @Override
                        public void onItemClick(View view, int position, ShoppingModel.SpecialListBean.SubListBean o) {

                            if ("category".equals(o.getLinkType())) {
                                Intent intent = new Intent(mContext, GoodsListActivity.class);
                                intent.putExtra("fromType", CLASSIFY_TYPE);
                                intent.putExtra("categoryId", o.getLinkTypeId());
                                intent.putExtra("goodsType", PLATFORM_TYPE);
                                intent.putExtra("title", o.getTitle());
                                intent.putExtra("mFromType", Constants.GOODSSOURCE_SPECIAL);
                                intent.putExtra("mFromTypeId", data.getSpecialSubjectId()+"");
                                mContext.startActivity(intent);
                            } else if ("url".equals(o.getLinkType())) {
                                Intent intent = new Intent(mContext, HotShopWebActivity.class);
                                intent.putExtra("title", o.getTitle());
                                intent.putExtra("url", o.getUrl());
                                mContext.startActivity(intent);
                            }
                        }
                    });
                    break;
                case SPECIAL_TYPE3:

                    tvSpecialName.setTextColor(mContext.getResources().getColor(R.color.shopping_cyan));
                    SpecialSubAdapter specialSubAdapter4 = new SpecialSubAdapter(mContext, SPECIAL_TYPE3);
                    rvSpecial1.setLayoutManager(new GridLayoutManager(mContext, 2));
                    ArrayList<ShoppingModel.SpecialListBean.SubListBean> subListBeans = new ArrayList<>();
                    for (int i = 0; i < (data.getSubList().size() > 2 ? 2 : data.getSubList().size()); i++) {
                        subListBeans.add(data.getSubList().get(i));
                    }

                    specialSubAdapter4.addAll(subListBeans);
                    rvSpecial1.setAdapter(specialSubAdapter4);
                    rvSpecial1.addItemDecoration(new DividerGridItemDecoration(mContext));
                    specialSubAdapter4.setOnItemClickListener(new OnItemClickListener<ShoppingModel.SpecialListBean.SubListBean>() {
                        @Override
                        public void onItemClick(View view, int position, ShoppingModel.SpecialListBean.SubListBean o) {

                            if ("category".equals(o.getLinkType())) {
                                Intent intent = new Intent(mContext, GoodsListActivity.class);
                                intent.putExtra("fromType", CLASSIFY_TYPE);
                                intent.putExtra("categoryId", o.getLinkTypeId());
                                intent.putExtra("goodsType", PLATFORM_TYPE);
                                intent.putExtra("title", o.getTitle());
                                intent.putExtra("mFromType", Constants.GOODSSOURCE_SPECIAL);
                                intent.putExtra("mFromTypeId", data.getSpecialSubjectId()+"");
                                mContext.startActivity(intent);
                            } else if ("url".equals(o.getLinkType())) {
                                Intent intent = new Intent(mContext, HotShopWebActivity.class);
                                intent.putExtra("title", o.getTitle());
                                intent.putExtra("url", o.getUrl());
                                mContext.startActivity(intent);
                            }
                        }
                    });


                    SpecialSubAdapter specialSubAdapter5 = new SpecialSubAdapter(mContext, SPECIAL_TYPE4);
                    rvSpecial2.setLayoutManager(new GridLayoutManager(mContext, 2));
                    if (data.getSubList().size() > 2) {
                        ArrayList<ShoppingModel.SpecialListBean.SubListBean> subListBeans1 = new ArrayList<>();
                        for (int i = 2; i < (data.getSubList().size() > 4 ? 4 : data.getSubList().size()); i++) {
                            subListBeans1.add(data.getSubList().get(i));
                        }

                        specialSubAdapter5.addAll(subListBeans1);
                    }

                    rvSpecial2.setAdapter(specialSubAdapter5);
                    rvSpecial2.addItemDecoration(new DividerGridItemDecoration(mContext));
                    specialSubAdapter5.setOnItemClickListener(new OnItemClickListener<ShoppingModel.SpecialListBean.SubListBean>() {
                        @Override
                        public void onItemClick(View view, int position, ShoppingModel.SpecialListBean.SubListBean o) {

                            if ("category".equals(o.getLinkType())) {
                                Intent intent = new Intent(mContext, GoodsListActivity.class);
                                intent.putExtra("fromType", CLASSIFY_TYPE);
                                intent.putExtra("categoryId", o.getLinkTypeId());
                                intent.putExtra("goodsType", PLATFORM_TYPE);
                                intent.putExtra("title", o.getTitle());
                                intent.putExtra("mFromType", Constants.GOODSSOURCE_SPECIAL);
                                intent.putExtra("mFromTypeId", data.getSpecialSubjectId()+"");
                                mContext.startActivity(intent);
                            } else if ("url".equals(o.getLinkType())) {
                                Intent intent = new Intent(mContext, HotShopWebActivity.class);
                                intent.putExtra("title", o.getTitle());
                                intent.putExtra("url", o.getUrl());
                                mContext.startActivity(intent);
                            }
                        }
                    });
                    break;
                case SPECIAL_TYPE4:
                    tvSpecialName.setTextColor(mContext.getResources().getColor(R.color.black));
                    SpecialSubAdapter specialSubAdapter6 = new SpecialSubAdapter(mContext, SPECIAL_TYPE5);
                    rvSpecial1.setLayoutManager(new GridLayoutManager(mContext, 4));
                    specialSubAdapter6.addAll(data.getSubList());
                    rvSpecial1.setAdapter(specialSubAdapter6);
                    rvSpecial1.addItemDecoration(new DividerGridItemDecoration(mContext));
                    specialSubAdapter6.setOnItemClickListener(new OnItemClickListener<ShoppingModel.SpecialListBean.SubListBean>() {
                        @Override
                        public void onItemClick(View view, int position, ShoppingModel.SpecialListBean.SubListBean o) {

                            if ("category".equals(o.getLinkType())) {
                                Intent intent = new Intent(mContext, GoodsListActivity.class);
                                intent.putExtra("fromType", CLASSIFY_TYPE);
                                intent.putExtra("categoryId", o.getLinkTypeId());
                                intent.putExtra("goodsType", PLATFORM_TYPE);
                                intent.putExtra("title", o.getTitle());
                                intent.putExtra("mFromType", Constants.GOODSSOURCE_SPECIAL);
                                intent.putExtra("mFromTypeId", data.getSpecialSubjectId()+"");
                                mContext.startActivity(intent);
                            } else if ("url".equals(o.getLinkType())) {
                                Intent intent = new Intent(mContext, HotShopWebActivity.class);
                                intent.putExtra("title", o.getTitle());
                                intent.putExtra("url", o.getUrl());
                                mContext.startActivity(intent);
                            }
                        }
                    });
                    break;
                case SPECIAL_TYPE5:
                    tvSpecialName.setTextColor(mContext.getResources().getColor(R.color.black));

                    SpecialSubAdapter specialSubAdapter7 = new SpecialSubAdapter(mContext, SPECIAL_TYPE0);
                    rvSpecial1.setLayoutManager(new GridLayoutManager(mContext, 2));
                    if (data.getSubList().size() > 0) {
                        ArrayList<ShoppingModel.SpecialListBean.SubListBean> subListBeans2 = new ArrayList<>();
                        for (int i = 0; i < (data.getSubList().size() > 2 ? 2 : data.getSubList().size()); i++) {
                            subListBeans2.add(data.getSubList().get(i));
                        }

                        specialSubAdapter7.addAll(subListBeans2);
                    }

                    rvSpecial1.setAdapter(specialSubAdapter7);
                    rvSpecial1.addItemDecoration(new DividerGridItemDecoration(mContext));
                    specialSubAdapter7.setOnItemClickListener(new OnItemClickListener<ShoppingModel.SpecialListBean.SubListBean>() {
                        @Override
                        public void onItemClick(View view, int position, ShoppingModel.SpecialListBean.SubListBean o) {

                            if ("category".equals(o.getLinkType())) {
                                Intent intent = new Intent(mContext, GoodsListActivity.class);
                                intent.putExtra("fromType", CLASSIFY_TYPE);
                                intent.putExtra("categoryId", o.getLinkTypeId());
                                intent.putExtra("goodsType", PLATFORM_TYPE);
                                intent.putExtra("title", o.getTitle());
                                intent.putExtra("mFromType", Constants.GOODSSOURCE_SPECIAL);
                                intent.putExtra("mFromTypeId", data.getSpecialSubjectId()+"");
                                mContext.startActivity(intent);
                            } else if ("url".equals(o.getLinkType())) {
                                Intent intent = new Intent(mContext, HotShopWebActivity.class);
                                intent.putExtra("title", o.getTitle());
                                intent.putExtra("url", o.getUrl());
                                mContext.startActivity(intent);
                            }
                        }
                    });
                    SpecialSubAdapter specialSubAdapter8 = new SpecialSubAdapter(mContext, SPECIAL_TYPE5);
                    rvSpecial2.setLayoutManager(new GridLayoutManager(mContext, 4));
                    if (data.getSubList().size() > 2) {
                        ArrayList<ShoppingModel.SpecialListBean.SubListBean> subListBeans3 = new ArrayList<>();
                        for (int i = 2; i < (data.getSubList().size() > 6 ? 6 : data.getSubList().size()); i++) {
                            subListBeans3.add(data.getSubList().get(i));
                        }

                        specialSubAdapter8.addAll(subListBeans3);
                    }

                    rvSpecial2.setAdapter(specialSubAdapter8);
                    rvSpecial2.addItemDecoration(new DividerGridItemDecoration(mContext));
                    specialSubAdapter8.setOnItemClickListener(new OnItemClickListener<ShoppingModel.SpecialListBean.SubListBean>() {
                        @Override
                        public void onItemClick(View view, int position, ShoppingModel.SpecialListBean.SubListBean o) {

                            if ("category".equals(o.getLinkType())) {
                                Intent intent = new Intent(mContext, GoodsListActivity.class);
                                intent.putExtra("fromType", CLASSIFY_TYPE);
                                intent.putExtra("categoryId", o.getLinkTypeId());
                                intent.putExtra("goodsType", PLATFORM_TYPE);
                                intent.putExtra("title", o.getTitle());
                                intent.putExtra("mFromType", Constants.GOODSSOURCE_SPECIAL);
                                intent.putExtra("mFromTypeId", data.getSpecialSubjectId()+"");
                                mContext.startActivity(intent);
                            } else if ("url".equals(o.getLinkType())) {
                                Intent intent = new Intent(mContext, HotShopWebActivity.class);
                                intent.putExtra("title", o.getTitle());
                                intent.putExtra("url", o.getUrl());
                                mContext.startActivity(intent);
                            }
                        }
                    });
                    break;
                case SPECIAL_TYPE6:

                    tvSpecialName.setTextColor(mContext.getResources().getColor(R.color.shopping_yellow));


                    SpecialSubAdapter specialSubAdapter9 = new SpecialSubAdapter(mContext, SPECIAL_TYPE6);
                    rvSpecial1.setLayoutManager(new GridLayoutManager(mContext, 2));

                    ArrayList<ShoppingModel.SpecialListBean.SubListBean> subListBeans4 = new ArrayList<>();
                    if (data.getSubList().size() > 1) {
                        for (int i = 1; i < (data.getSubList().size() > 3 ? 3 : data.getSubList().size()); i++) {
                            subListBeans4.add(data.getSubList().get(i));
                        }

                        specialSubAdapter9.addAll(subListBeans4);
                        specialSubAdapter9.setOnItemClickListener(new OnItemClickListener<ShoppingModel.SpecialListBean.SubListBean>() {
                            @Override
                            public void onItemClick(View view, int position, ShoppingModel.SpecialListBean.SubListBean o) {

                                if ("category".equals(o.getLinkType())) {
                                    Intent intent = new Intent(mContext, GoodsListActivity.class);
                                    intent.putExtra("fromType", CLASSIFY_TYPE);
                                    intent.putExtra("categoryId", o.getLinkTypeId());
                                    intent.putExtra("goodsType", PLATFORM_TYPE);
                                    intent.putExtra("title", o.getTitle());
                                    intent.putExtra("mFromType", Constants.GOODSSOURCE_SPECIAL);
                                    intent.putExtra("mFromTypeId", data.getSpecialSubjectId()+"");
                                    mContext.startActivity(intent);
                                } else if ("url".equals(o.getLinkType())) {
                                    Intent intent = new Intent(mContext, HotShopWebActivity.class);
                                    intent.putExtra("title", o.getTitle());
                                    intent.putExtra("url", o.getUrl());
                                    mContext.startActivity(intent);
                                }
                            }
                        });

                        rvSpecial1.setAdapter(specialSubAdapter9);
                        rvSpecial1.addItemDecoration(new DividerGridItemDecoration(mContext));
                        SpecialSubAdapter specialSubAdapter10 = new SpecialSubAdapter(mContext, SPECIAL_TYPE7);
                        rvSpecial2.setLayoutManager(new GridLayoutManager(mContext, 4));
                        if (data.getSubList().size() > 3) {
                            ArrayList<ShoppingModel.SpecialListBean.SubListBean> subListBeans5 = new ArrayList<>();
                            for (int i = 3; i < (data.getSubList().size() > 7 ? 7 : data.getSubList().size()); i++) {
                                subListBeans5.add(data.getSubList().get(i));
                            }

                            specialSubAdapter10.addAll(subListBeans5);
                        }

                        rvSpecial2.setAdapter(specialSubAdapter10);
                        rvSpecial2.addItemDecoration(new DividerGridItemDecoration(mContext));
                        specialSubAdapter10.setOnItemClickListener(new OnItemClickListener<ShoppingModel.SpecialListBean.SubListBean>() {
                            @Override
                            public void onItemClick(View view, int position, ShoppingModel.SpecialListBean.SubListBean o) {

                                if ("category".equals(o.getLinkType())) {
                                    Intent intent = new Intent(mContext, GoodsListActivity.class);
                                    intent.putExtra("fromType", CLASSIFY_TYPE);
                                    intent.putExtra("categoryId", o.getLinkTypeId());
                                    intent.putExtra("goodsType", PLATFORM_TYPE);
                                    intent.putExtra("title", o.getTitle());
                                    intent.putExtra("mFromType", Constants.GOODSSOURCE_SPECIAL);
                                    intent.putExtra("mFromTypeId", data.getSpecialSubjectId()+"");
                                    mContext.startActivity(intent);
                                } else if ("url".equals(o.getLinkType())) {
                                    Intent intent = new Intent(mContext, HotShopWebActivity.class);
                                    intent.putExtra("title", o.getTitle());
                                    intent.putExtra("url", o.getUrl());
                                    mContext.startActivity(intent);
                                }
                            }
                        });
                    }

                    break;
                case SPECIAL_TYPE7:
                    tvSpecialName.setTextColor(mContext.getResources().getColor(R.color.shopping_yellow));
                    break;
            }


        }
    }

}
